var newCli = {
    
    init: function(){
        newCli.insert();
        newCli.getMapData();
        newCli.cleanMap();
        mask.setCliMask();
    },

    insert: function(){
        var form = document.getElementById('newCliForm');
                
        if(form){
            form.cliOkButton.onclick = function(){
                if(validation.newCliData(form)){
                    form.submit(); 
                }   
            } 
        } 
    },
    
    getMapData: function(){
        var form = document.getElementById('newCliForm'),
            address = {};
        
        if(form){
            form.cliMapButton.onclick = function(){
                if(validation.showMapData(form)){
                    address.street = form.cliStreetInput.value.replace(/\s+/g, "+");
                    address.number = form.cliNumbInput.value;
                    address.zipcode = form.cliZipInput.value;
                    address.city = form.cliCityInput.value.replace(/\s+/g, "+"); 
                    newCli.showMapAddress(address);
                }   
            }
        }
    },
    
    showMapAddress: function(address){
        var googlesrc = "http://maps.google.com/maps/api/staticmap?center="+address.city+","+address.street+","+address.number+"&format=png8&markers=size:mid%7Ccolor:red%7C"+address.city+","+address.street+","+address.number+"&zoom=15&size=300x300&sensor=false";			
            google = document.getElementById('google');
					
        google.innerHTML = "";
				
        google.className = "google";
        google.innerHTML = "<img width='300px' height='300px' id='googleimg' src="+googlesrc+">";
			
    },
    
    cleanMap: function(){
        var form = document.getElementById('newCliForm');
        
        if(form){
            form.cliResetButton.onclick = function(){
                google = document.getElementById('google');
                google.innerHTML = "";
            }
        }
    }
    
};

newCli.init();


